function getLanguage(_this) {
  return _this.$store.getters.getLanguage;
}

function categoryLoading(_this) {
  _this
    .$http({
      url: "/api/index/category/musicCategoryData",
      params: {
        language: getLanguage(_this)
      }
    })
    .then(function(res) {
      _this.categoryList = res.data.data;
    });
}

function albumLoading(_this, options) {
  _this
    .$http({
      url: "/api/index/album/index",
      params: options
    })
    .then(res => {
      if (res.data.code === 1) {
        _this.AlbumList = res.data.data;
      }
    });
}

function albumDetailLoading(_this) {
  _this
    .$http({
      url: "/api/index/album/albumDetail",
      params: {
        id: _this.id
      }
    })
    .then(function(res) {
      _this.list = res.data.data.data;
      _this.albumInfo = res.data.data.albumData;
    });
}

function getLrcArr(_this) {
  // 请求歌词
  _this
    .$http({
      url: "/api/index/song/getLrc",
      method: "get",
      params: {
        id: _this.play.playId
      }
    })
    .then(function(res) {
      if (res.data.code == 1) {
        _this.lrcArr = _this.$common.lrcSplit(res.data.data.lrcString);
        _this.$store.commit("setPlayer", ["playLrcArr", _this.lrcArr]);
      }
    });
}

function searchRes(_this) {
  _this
    .$http({
      url: "/api/index/album/search",
      params: {
        namePY: _this.value,
        language: getLanguage(_this)
      }
    })
    .then(res => {
      if (res.data.code == 1) {
        _this.searchData = res.data.data;
      }
    });
}
export default {
  categoryLoading,
  albumLoading,
  albumDetailLoading,
  getLrcArr,
  searchRes
};
